﻿@inject SettingService _settingService
@inject CategoryService _categoryService
@inject NavigationService _navigationService
@{
    var setting = _settingService.GetGeneralSetting();
    var categories = _categoryService.GetCategoriesAsync().Result;
    var navigations = _navigationService.GetNavigationsAsync().Result;

    var path = ViewContext.HttpContext.Request.Path.Value;
}
<nav class="navbar navbar-expand-lg navbar-dark bg-primary mb-3">
    <a class="navbar-brand" href="/">
        @setting.SiteName
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            @foreach (var item in navigations)
            {
                <li class="nav-item">
                    <a class="nav-link @if (path == item.Url) { <text>active</text>} " href="@item.Url">
                        @item.Name
                    </a>
                </li>
            }
        </ul>
    </div>
</nav>
@if (_settingService.GetGeneralSetting().IsClosed && User.IsAdmin())
{
    <div class="alert alert-warning text-center">
        <h3><i class="fa fa-info-circle"></i> 站点处于关闭状态，除管理员外，任何人将无法正常访问！</h3>
    </div>
}